# Maintainer: David Runge <dvzrv@archlinux.org>

_name=wally-cli
pkgname=zsa-wally-cli
pkgver=2.0.1
pkgrel=5
pkgdesc="Flash your ZSA Keyboard the EZ way"
arch=(loong64 x86_64)
url="https://github.com/zsa/wally-cli"
license=(MIT)
depends=(
  glibc
  zsa-udev
)
makedepends=(
  go
  libusb
)
source=($pkgname-$pkgver.tar.gz::https://github.com/zsa/$_name/archive/$pkgver-linux.tar.gz)
sha512sums=('998035e5d932892245cd6db13682501dc5e65a79b724e9ed66733c955bf6646c46c5cb59214160cd5bc5710949dcd43f054ae72b5adb757aa12e3cece92df4bc')
b2sums=('876a1e237d08c43b90c89ef596ad9015a6f641d3282296b9e3c846a7bf7fa27988605902deaae9e2c95b9c8bf10a2e2304c3ad5b1812001a45b6ca93eb0210bd')

build() {
  cd $_name-$pkgver-linux
  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export CGO_LDFLAGS="$LDFLAGS"
  export GOPATH="$srcdir"
  export GOFLAGS="-buildmode=pie -mod=readonly -modcacherw"

  go build -ldflags "-compressdwarf=false -linkmode external" .
}

package() {
  depends+=(
    libusb libusb-1.0.so
  )

  install -vDm 755 $_name-$pkgver-linux/$_name -t "$pkgdir/usr/bin/"
  install -vDm 644 $_name-$pkgver-linux/license.md -t "$pkgdir/usr/share/licenses/$pkgname/"
}
